const TeacherModel = require('../models/TeacherModel')

const TeacherService = {
  add: async ({ username, mycourses }) => {
    return TeacherModel.create({ username, mycourses })
  },

  delList: async ({ username }) => {
    return TeacherModel.deleteOne({ username })
  },

  getCourse: async ({ username }) => {
    return TeacherModel.find({ username }, ['mycourses'])
  },

  postCourse: async ({ username }, { mycourses }) => {
    return TeacherModel.updateOne({ username }, { mycourses })
  }
}

module.exports = TeacherService
